// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import axios from 'axios'
import qs from 'qs'
/* 设置axios模块的域名代理地址 */
axios.defaults.baseURL="/exam";
/* 设置axios的全局变量属性 */
Vue.prototype.$http = axios;
/* 设置qs的全局变量属性 */
Vue.prototype.$qs = qs;

Vue.config.productionTip = false

/* 定义导航钩子 */
/* to:要到达的路由对象 */
/* from:从哪里来的的路由对象 */
/* next 用来定义要达到路由地址 domain */
router.beforeEach(function(to,from,next){
    
    //从本地存储获取用户登录信息
    var name = sessionStorage.getItem("name");
    console.log("name="+name)
    //判断哪些需要拦截
    if(to.meta.isLogin){
      if(name==null){
        //回到登录页面
        next("/")
      }else{
        //不拦截
        next();
      }
    }else{
      //不拦截
      next();
    }

})


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',

})
